Cute little puzzle! Now to go insane optimizing the cost...